import request from '@/util/request'
import type {SysRole} from "@/api/system/role/type";
import type {PageType} from "@/api/type";

enum API {
    SYS_ROLE_URL = '/system/role',
    SYS_ROLE_ID_BY_USER_URL = '/system/role/user/userId',
    SYS_ROLE_INFO_URL = '/system/role/info',
    SYS_ROLE_PAGE_URL = '/system/role/page',
}

export function reqGetSysRolePage(params: object) {
    return request<PageType<SysRole>>({
        url: API.SYS_ROLE_PAGE_URL,
        method: 'get',
        params
    })
}
export function reqGetSysRoleInfo(roleId:string) {
    return request<SysRole>({
        url: API.SYS_ROLE_INFO_URL+"/"+roleId,
        method: 'get',
    })
}
export function reqAddSysRole(sysRole: SysRole) {
    return request({
        url: API.SYS_ROLE_PAGE_URL,
        method: 'post',
        data: sysRole
    })
}
export function reqModifySysRole(sysRole: SysRole) {
    return request({
        url: API.SYS_ROLE_URL,
        method: 'put',
        data: sysRole
    })
}
export function reqDeleteSysRoleById(roleId: string | number) {
    return request({
        url: API.SYS_ROLE_URL+"/"+roleId,
        method: 'delete',
    })
}
export function reqGetSysRoleIdByUserId(userId: string | number) {
    return request<string[]>({
        url: API.SYS_ROLE_ID_BY_USER_URL+"/"+userId,
        method: 'get',
    })
}
